import { WeaTools,WeaInput } from 'ecCom'
import {Icon,Row,Col} from 'antd' 


import Immutable from 'immutable'
const is = Immutable.is;


class weaCrmShowGroup extends React.Component {
    constructor(props) {
        super(props);
        this.state={
            showGroup:true
        }
    }
    shouldComponentUpdate(nextProps,nextState) {
        return !is(this.state,nextState)||
        !is(this.props.children,nextProps.children)
    }

    render() {
        const {showGroup} = this.state;
        const {title,children,needTigger} = this.props;
        return (
            <div>
                <div className="wea-crm-table-edit" >
                    <Row className="wea-title">
                        <Col span="20">
                            <div>{title}</div>
                        </Col>
                        {needTigger &&
                            <Col span="4" style={{textAlign:"right",paddingRight:10,fontSize:12}}>
                                <Icon type={showGroup ? 'up' : 'down'} onClick={()=>this.setState({showGroup:!showGroup})}/>
                            </Col>
                        }
                    </Row>
                    <Row className="wea-content" style={{display:showGroup ? "block":"none"} }>
                        <Col className="wea-form-cell" span={24}>
                            {children}
                        </Col>
                    </Row>
                 </div>
            </div>
        )
    }
}

export default weaCrmShowGroup;
